var Sample = Window03.extend({
	parent:null,
	vessel:null,
	flow:null,
	status:true,
	runningAction:null,
	runningAction1:null,
	ctor:function (parent,flow, tag) {
		this._super(parent,flow, tag);
		this.parent=parent;
		this.flow=flow;
	},
	initSp:function (){
		this.uv1800_1=new Button03(this.rootNode,2,TAG_ITEM_UV_BAFFLE,
				"#action/UV1800-1.png",this.eventMenuCallback,this);
		this.uv1800_1.setPosition(gg.c_width,gg.c_height+50);
		this.uv1800_1.setVisible(true);
		
		this.uv1800=new cc.Sprite("#action/UV1800-1.png");
		this.uv1800.setPosition(gg.c_width,gg.c_height+50);
		this.uv1800.setVisible(false);
		
		this.uv1800_2=new Button03(this.rootNode,2,TAG_ITEM_UV_BAFFLE1,
				"#action/UV1800-3.png",this.eventMenuCallback,this)
		this.uv1800_2.setPosition(gg.c_width,gg.c_height+50);
		this.uv1800_2.setVisible(false);
		
		this.uv1800_4=new Button03(this.rootNode,4,TAG_UV1800_OCCLUSION,"#action/UV1800-4.png",this.eventMenuCallback,this);
		this.uv1800_4.setPosition(gg.c_width,gg.c_height*1.149);
		this.uv1800_4.setVisible(false);
		
		this.vessel=new Button03(this.rootNode,2,TAG_ITEM_VESSEL5,"#equitment/vessel2.png",this.eventMenuCallback,this);
		this.vessel.setPosition(gg.c_width*1.35,gg.c_height);
		
		this.vessel1=new Button03(this.rootNode,20,TAG_ITEM_VESSEL6,"#equitment/vessel2.png",this.eventMenuCallback,this);
		this.vessel1.setPosition(gg.c_width*1.4, gg.c_height);
		this.vessel1.setVisible(false);
		
		this.vessel2=new Button03(this.rootNode,20,TAG_ITEM_VESSEL_2,"#equitment/vessel3.png",this.eventMenuCallback,this);
		this.vessel2.setPosition(gg.c_width*1.4-317+gg.c_width*0.1, gg.c_height+40);
		this.vessel2.setVisible(false);
		
		this.pull=new Button03(this.rootNode,21,TAG_ITEM_PULL,"#equitment/pull.png",this.eventMenuCallback,this);
		this.pull.setPosition(gg.c_width*0.875,gg.c_height*0.945);
		this.pull.setVisible(true);
		
		this.equit=new Button03(this.rootNode,5,TAG_ITEM_EQUIT1,"#equitment/equit1.png",this.eventMenuCallback,this);
		this.equit.setPosition(gg.c_width*1.5,gg.c_height);
		this.equit.setVisible(false);
		
		this.equit1=new Button03(this.rootNode,6,TAG_ITEM_EQUIT2,"#equitment/equit2.png",this.eventMenuCallback,this);
		this.equit1.setPosition(gg.c_width*1.5,gg.c_height);
		this.equit1.setVisible(false);
		
		this.equit2=new Button03(this.rootNode,5,TAG_ITEM_EQUIT3,"#equitment/equit3.png",this.eventMenuCallback,this);
		this.equit2.setPosition(gg.c_width*1.49,gg.c_height*1.3);
		this.equit2.setVisible(false);
		
		this.rootNode.addChild(this.uv1800,10);
		this.initAction();
		this.initAction1();
	},
	initAction:function() {
		var animFrames = [];
		for (var i = 1; i < 4; i++) {
			var str = "action/UV1800-" + i + ".png";
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation =new cc.Animation(animFrames, 0.1);
		this.runningAction = cc.repeat(cc.animate(animation), 1);
		this.runningAction.retain();
	},
	initAction1:function() {
		var animFrames = [];
		for (var i = 3; i >0; i--) {
			var str = "action/UV1800-" + i + ".png";
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation =new cc.Animation(animFrames, 0.1);
		this.runningAction1 = cc.repeat(cc.animate(animation), 1);
		this.runningAction1.retain();
	},
	eventMenuCallback:function(pSender){
		if(!this.flow.checkTag(pSender.getTag())){
			// 是否可以触发
			_.error();
			ll.tip.mdScore(-3);
			return;
		} else {
			if(this.status==true){
				_.clever();
				ll.tip.mdScore(10);
			}
		}
		var action = this.flow.flow.action;
		var func = cc.callFunc(this.close, this);
		var func1 = cc.callFunc(this.checkActionDone,this);
		var func2=cc.callFunc(function(){
			this.flow.next();
			this.status=true;
		}, this);
		switch (pSender.getTag()) {
		case TAG_ITEM_UV_BAFFLE:
			if(action==ACTION_DO1){
				if(this.status==true){
					this.status=false;
					cc.log("打开样品室挡板动作");
					this.uv1800_1.setVisible(false);
					this.uv1800.setVisible(true);
					this.uv1800_4.setVisible(true);
					var seq = cc.sequence(this.runningAction,func1,func2);
					this.uv1800.runAction(seq);
				}
				
			}else if(action==ACTION_DO4){
				if(this.status==true){
					this.status=false;
					cc.log("打开样品室挡板动作");
					this.vessel2.setVisible(true);
					this.uv1800_1.setVisible(false);
					this.uv1800.setVisible(true);
					var seq = cc.sequence(this.runningAction,func1,func2);
					this.uv1800.runAction(seq);
				}
			}else if(action==ACTION_DO5){
				if(this.status==true){
					this.status=false;
					cc.log("打开样品室挡板动作");
					this.vessel2.setVisible(true);
					this.uv1800_1.setVisible(false);
					this.uv1800.setVisible(true);
					this.uv1800_4.setVisible(true);
					var seq = cc.sequence(this.runningAction,func1,func2);
					this.uv1800.runAction(seq);	
				}
			}
			break;
		case TAG_ITEM_UV_BAFFLE1:
			if(action==ACTION_DO2){
				if(this.status==true){
					this.status=false;
					cc.log("关闭样品室挡板动作");
					this.uv1800_2.setVisible(false);
					this.uv1800.setVisible(true);
					this.uv1800_4.setVisible(false);
					var seq = cc.sequence(this.runningAction1,func,func1,cc.delayTime(0.5),func2);
					this.uv1800.runAction(seq);
				}
			}else if(action==ACTION_DO3){
				if(this.status==true){
					this.status=false;
					cc.log("关闭样品室挡板动作");
					this.uv1800_2.setVisible(false);
					this.uv1800.setVisible(true);
					this.uv1800_4.setVisible(false);
					var seq = cc.sequence(this.runningAction1,func1,func2);
					this.uv1800.runAction(seq);
					this.pull.setVisible(true);
				}
			}
			break;
		case TAG_ITEM_VESSEL_2:
			var move4=new cc.MoveBy(0.5,cc.p(0,50));
			var move5=new cc.MoveBy(0.5,cc.p(317-gg.c_width*0.15, 0));
			var move6=new cc.MoveBy(0.5,cc.p(0,-80));
	
			var move14=new cc.MoveBy(0.5,cc.p(0, -80));
			var move15=new cc.MoveBy(0.5,cc.p(317-gg.c_width*0.1, 0));
			var move16=new cc.MoveBy(0.5,cc.p(0,50));
			if(this.status==true){
				this.status=false;
				if(action==ACTION_DO1){
					this.vessel2.setVisible(false);
					this.vessel.setVisible(true);
					this.vessel.setLocalZOrder(3);
					this.vessel.runAction(cc.sequence(move4,move5,move6,func1,func2));
					this.parent.vessel.setVisible(true);
					this.parent.equitment.vessel1.setVisible(true);
					this.vessel2.setVisible(true);
				}else if(action==ACTION_DO2){
					this.vessel2.setVisible(false);
					this.vessel1.setVisible(true);
					this.vessel1.runAction(cc.sequence(move16,move15,move14,func1,func2));
					this.parent.vessel1.setVisible(true);
					this.parent.equitment.vessel2.setVisible(true);
					this.uv1800.setVisible(false);
					this.uv1800_2.setVisible(true);
				}
			}
			break;
		case TAG_ITEM_VESSEL5:
			var move1=new cc.MoveBy(0.5,cc.p(0,80));
			var move2=new cc.MoveBy(0.5,cc.p(-317+gg.c_width*0.15, 0));
			var move3=new cc.MoveBy(0.5,cc.p(0,-50));
			if(this.status==true){
				this.status=false;
				if(action==ACTION_DO1){
					this.vessel.runAction(cc.sequence(move1,move2,cc.spawn(move3,cc.callFunc(function() {
						this.equit.setVisible(true);
						this.equit1.setVisible(true);
						this.equit2.setVisible(true);
						this.equit2.runAction(cc.moveTo(1,cc.p(gg.c_width*1.49,gg.c_height*0.95)));
					}, this)),cc.delayTime(1),cc.callFunc(function(){
						this.equit.setVisible(false);
						this.equit1.setVisible(false);
						this.equit2.setVisible(false);
					},this),func1,func2));
					this.parent.vessel.setVisible(false);
					this.parent.equitment.vessel1.setVisible(false);
					this.uv1800.setVisible(false);
					this.uv1800_2.setVisible(true);
				}else if(action==ACTION_DO3){
					this.vessel.runAction(cc.sequence(move1,move2,move3,func1,func2));
					this.parent.vessel.setVisible(false);
					this.parent.equitment1.vessel1.setVisible(false);
					this.uv1800.setVisible(false);
					this.uv1800_2.setVisible(true);
				}
			}
			break;
		case TAG_ITEM_VESSEL6:
			var move1=new cc.MoveBy(0.5,cc.p(0,80));
			var move2=new cc.MoveBy(0.5,cc.p(-317+gg.c_width*0.1, 0));
			var move3=new cc.MoveBy(0.5,cc.p(0,-50));
			if(this.status==true){
				this.status=false;
				if(action==ACTION_DO1){
					this.vessel1.runAction(cc.sequence(move1,move2,move3,func1,func2));
					this.parent.vessel1.setVisible(false);
					this.parent.equitment.vessel2.setVisible(false);
					this.uv1800.setVisible(false);
					this.uv1800_2.setVisible(true);
				}
			}
			break;
		case TAG_ITEM_PULL:
			if(this.status==true){
				this.status=false;
				if(action!=ACTION_DO1){
					pSender.runAction(cc.sequence(cc.callFunc(function() {
						this.pull.setVisible(false);	
					},this),func,cc.delayTime(0.5),func2));
				}
			}
			break;
		default:
			break;
		}
	},
	checkActionDone:function(pSender){
		var tag=pSender.getTag();
		var action = this.flow.flow.action;
		if(tag==TAG_ITEM_VESSEL5){
			this.vessel.setVisible(false);
			this.uv1800_4.setVisible(false);
		}else if(tag==TAG_ITEM_VESSEL6){
			this.vessel1.setVisible(false);
			this.uv1800_4.setVisible(false);
		}else if(tag==TAG_ITEM_UV_BAFFLE){
			if(action==ACTION_DO1){
				this.uv1800.setVisible(true);
			}else if(action==ACTION_DO5){
				this.vessel.setVisible(true);
			}
		}
		
	}
});